package com.yuyue.dronesystem.controllers;

import java.util.Optional;


import com.yuyue.dronesystem.entities.Site;
import com.yuyue.dronesystem.repository.SiteRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * DefaultController
 */
@Controller
public class DefaultController {

    @Autowired
    SiteRepository siteRepository;

    @GetMapping(value = "/site/{id}")
    @ResponseBody
    public Site siteTest(@PathVariable Integer id) {
        // siteRepository.save(new Site(40,"123",1.1,2.1));
        Optional<Site> site = siteRepository.findById(id);
        return site.get();
    }
}